Conversation
0pcom
force-pushed
the
unix-heap-reserve
branch
from
September 2, 2026 08:14
68058ae to
ae3954c
Compare
Contributor
Author
|
Fixed the CI failures: the 16GB literal did not compile on 32-bit targets (ARM/MIPS) — Go type-checks the dead branch too. The reservation size is now a constant derived from TargetBits ( |
0pcom
force-pushed
the
unix-heap-reserve
branch
from
September 2, 2026 09:05
ae3954c to
5572fc4
Compare
0pcom
force-pushed
the
unix-heap-reserve
branch
from
September 12, 2026 19:10
5572fc4 to
27d6614
Compare
The heap reserved a flat 1GB of virtual address space, so any allocation approaching 1GB failed regardless of how much memory the system had. One example is a scrypt key derivation buffer with N=1<<20 and r=8. The reservation is virtual, so pages cost physical RAM only when first touched, and allocateHeap still halves its request if mmap refuses. 32-bit targets keep the 1GB reserve.
0pcom
force-pushed
the
unix-heap-reserve
branch
from
September 30, 2026 18:15
27d6614 to
5b61663
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5760.
allocateHeap caps the heap at 1GB on every target, so with -gc=conservative or
-gc=precise any single allocation approaching 1GB fails with out of memory no
matter how much system RAM is free. The case that hit this was a 1GiB scrypt
key derivation buffer (N=1<<20, r=8) in the skycoin wallet, on a machine with
16GB free.
Reserve 16GB of virtual address space on 64-bit targets instead. The mmap is a
reservation, not a commitment. Pages cost physical memory only when first
touched, and the existing halve on failure loop still adapts when the map is
refused. 32-bit targets keep the 1GB cap. The growHeap comment already points
this way, in "If we run out of memory, we should consider increasing
heapMaxSize on 64-bit systems."
Verified on linux/amd64 with -gc=conservative. Before the change,
make([]byte, 1536<<20) gives a fatal out of memory error with 15GB free. After
it, the same allocation succeeds and is usable across the whole range.
One behavioral note. Under the blocks GC on 64-bit hosts the practical limit
becomes actual system memory, matching the boehm default and big Go, so true
exhaustion surfaces as OS memory pressure rather than a fatal error at an
arbitrary 1GB.